package com.e.dianshang.service.impl;

import com.e.dianshang.mapper.GetTicketMapper;
import com.e.dianshang.pojo.GetTicket;
import com.e.dianshang.service.GetTicketService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @Author Tian同學
 * @Date 2020/11/9 19:00
 * @Version 1.0
 */
@Service("getTicketService")
public class GetTicketServiceImpl implements GetTicketService {

    @Resource
    GetTicketMapper getTicketMapper;

    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,rollbackFor = {Throwable.class})
    public int getTktByName(GetTicket getTicket) {
//        GetTicket getTicket=new GetTicket();
        getTicket.setGetTime(new Date());
//        getTicket.setOpenid(openid);
//        getTicket.setTktId(tktId);
        return getTicketMapper.insertSelective(getTicket);
    }

    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    public List<GetTicket> getTktBrand(String openid, Integer brandId) {
        GetTicket getTicket=new GetTicket();

        getTicket.setOpenid(openid);
        getTicket.setBrandId(brandId);

        return getTicketMapper.select(getTicket);
    }
}
